package com.byxy.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.byxy.entity.User;

public class LoginInterceptor extends HandlerInterceptorAdapter {
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
		Object user=request.getSession().getAttribute("user");
		if(user!=null&&user instanceof User) {
			return true;
		}
		request.getRequestDispatcher("/WEB-INF/login.jsp").forward(request, response);
		return false;
	}
}
